package com.JdkProxy.firstexample;

import com.JdkProxy.firstexample.Animal.Animal;
import com.JdkProxy.firstexample.Animal.Animalimpl.Dog;
import com.JdkProxy.firstexample.person.Person;
import com.JdkProxy.firstexample.person.impl.Docker;
import com.JdkProxy.firstexample.person.impl.Student;
import com.JdkProxy.firstexample.utils.Proxyutils;

/**
 * @User c.c
 * @Since 2022/10/24
 * @Time 9:47
 * @Description
 */

public class TestPerson {

  public static void main(String[] args) {
//    getStudent();
//    getDoctor();
    getDog();
  }

  private static void getStudent() {
    JDKDynamicProxy proxy = new JDKDynamicProxy(new Student("mhyx", 25));
    Person person = Proxyutils.getClass(Person.class, proxy);

    person.sleep();
    person.wakeup();
    person.eat();
    System.out.println(person.getAge());
    System.out.println(person.getName());
  }

  private static void getDoctor(){
    JDKDynamicProxy proxy = new JDKDynamicProxy(new Docker("杨永信", 99));
    Person docker = Proxyutils.getClass(Person.class, proxy);
    docker.sleep();
    docker.wakeup();
    docker.eat();
    System.out.println(docker.getAge());
    System.out.println(docker.getName());
  }

  private static void getDog(){
    JDKDynamicProxy proxy = new JDKDynamicProxy(new Dog(23, "哈士奇"));
    Animal dog = Proxyutils.getClass(Animal.class, proxy);
    dog.eat();
    dog.sleep();
    dog.wakeup();
    System.out.println(dog.Animalage());
    System.out.println(dog.Animalname());
  }
}
